/*
 * ticketinfo_dao.h
 *
 *  Created on: 2013-2-19
 *      Author: panqiuhui
 */

#ifndef TICKETINFO_DAO_H_
#define TICKETINFO_DAO_H_
#include <stdbool.h>
#include "db_connection.h"
#include "../common_struct/traininfo.h"
#include "../common_struct/ticketlist.h"

//查询余票信息，成功返回true并将结果添加到ticketlist中，失败返回false
bool search_ticket_left(const struct ticket_left_request *request,
		TicketList *ticketlist);

//买票，成功返回true并将票的信息保存在ticket中，购买失败返回false
bool buy_ticket(const struct buy_ticket_request *request,
		struct ticket_saled_info *ticket);

//计算一个车次一共有多少座位
int calculate_seat_count(const char *trainID);

//计算一个车次已经卖出多少张票
int calculate_ticket_saled(const char *trainID, const char *departDate);

#endif /* TICKETINFO_DAO_H_ */
